package top.kangyaocoding.ltzf.payment.h5pay.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import top.kangyaocoding.ltzf.utils.SignUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author K·Herbert
 * @Description 退款请求
 * @Date 2024-05-14 20:04
 */
@Data
public class RefundOrderRequest {
    /*商户号*/
    @JsonProperty("mch_id")
    private String mchId;
    /*商户订单号*/
    @JsonProperty("out_trade_no")
    private String outTradeNo;
    /*商户退款单号*/
    @JsonProperty("out_refund_no")
    private String outRefundNo;
    /*退款金额*/
    @JsonProperty("refund_fee")
    private String refundFee;
    /*退款描述*/
    @JsonProperty("refund_desc")
    private String refundDesc;
    /*退款通知地址，通知URL必须为直接可访问的URL，不允许携带查询串，要求必须为http或https地址*/
    @JsonProperty("notify_url")
    private String notifyUrl;

    private final String timestamp = String.valueOf(System.currentTimeMillis() / 1000);

    /*创建签名*/
    public String createSign(String key) {
        Map<String, String> dataMaps = new HashMap<>();
        dataMaps.put("mch_id", getMchId());
        dataMaps.put("out_trade_no", getOutTradeNo());
        dataMaps.put("out_refund_no", getOutRefundNo());
        dataMaps.put("refund_fee", getRefundFee());
        dataMaps.put("timestamp", getTimestamp());
        return SignUtils.createSign(dataMaps, key);
    }

}
